package cn.mrcode.fd.blog.buutil.restfull;

import com.alibaba.fastjson.JSONObject;

/**
 * 返回json结果实体
 * @author zhuqiang
 * @version V1.0
 * @date 2016/7/14 0014 16:01
 */
public class RestFulResult implements Cloneable{
    private int status = 200; //http状态可用于后台统一的跳转方案，或则标识其他作用"
    private String code = "0" ; // 错误代码：'0' = 正常， -1：'系统致命错误，其他的则为对应的错误码'
    private Object data; // 接口返回的数据
    private String msg; // 错误码对应的错误信息

    @Override
    public RestFulResult clone(){
        try {
            return (RestFulResult) super.clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return null;
    }
    public String serializeJson(){
        return JSONObject.toJSONString(this);
    }
    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }
}
